import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/src/widgets/framework.dart';

import '../../model/event_manage/event_manage_model.dart';

class AddEventFollowViewModel extends BaseViewModel{
  AddEventFollowViewModel(BuildContext context,{@required this.eventId}) : super(context);

  final dynamic eventId;


  var format = ['yyyy', '-', 'mm', '-', 'dd', ' ', 'HH', ':', 'mm', ':', 'ss'];

  var handleTime = "";

  List<String> files = [];

  var detail = "";

  var model = EventManageModel();

  Future<void> createFollow(bool isEndFollow) async {
    if (detail.isNullOrEmpty()) {
      showToast("请输入处理记录");
      return;
    }

    handleTime = DateTime.now().toDateStr(format);
    showLoadingDialog(msg: "提交中...");
    try {
      await model.createFollow(
          emergencyEventManageId: eventId,
          handleTime: handleTime,
          detail: detail,
          attatchIds: files,isEndFollow: isEndFollow);
      hideDialog();
      showToast("提交成功");
      finish(data: true);
    } catch (e) {
      showToast(NetErrorUtils.getNetError(e));
      hideDialog();
    }
  }
}